home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-12-22 | 6.8 KB | 304 lines | [TEXT/CWIE] |
- // CCheckboxes.cp -- window methods
-
- #include "CCheckboxes.h"
-
- #include <UEnvironment.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LStream.h>
- #include <LTabGroup.h>
- #include <LCheckBox.h>
- #include <LAMControlImp.h>
- #include <LGACheckboxImp.h>
- #include <LDisclosureTriangle.h>
- #include <LGADisclosureTriangleImp.h>
- #include <LStaticText.h>
- #include <LAMStaticTextImp.h>
- #include <LGAStaticTextImp.h>
- #include <LTextGroupBox.h>
- #include <LAMControlViewImp.h>
- #include <LGATextGroupBoxImp.h>
- #include <CustomControls.h>
- #include <LToggleButton.h>
- #include <LBevelButton.h>
- #include <LAMBevelButtonImp.h>
- #include <LGABevelButtonImp.h>
- #include <CTextUtils.h>
-
- #include "DDocData.h"
- #include "DModalCheckboxesData.h"
- #include "DModalRadiosData.h"
- #include "DModalTextData.h"
- #include "DModalStuffData.h"
- #include "DModalBarsData.h"
- #include "DModelessCheckboxesData.h"
- #include "DModelessRadiosData.h"
- #include "DModelessTextData.h"
- #include "DModelessStuffData.h"
- #include "DModelessBarsData.h"
- #include "EverythingCmds.h"
-
- const MessageT msgStandard = 'Stad';
- const MessageT msgXx = 'Xx ';
- const MessageT msgLR = 'LR ';
- const MessageT msgLR2 = 'LR2 ';
- const MessageT msgLR3 = 'LR3 ';
- const MessageT msgLR4 = 'LR4 ';
- const MessageT msgCheckbox = 'Chex';
- const MessageT msgCheckbox2 = 'Che2';
- const MessageT msgNext = 'Next';
- const MessageT msgNext2 = 'Nex2';
-
- #define PPob_CheckboxesID 202
- #define RidL_CheckboxesID 202
-
- Boolean CCheckboxes::sIsRegistered = false;
-
- //----------
- CCheckboxes* CCheckboxes::CreateCheckboxes (
- LCommander* inSuperCommander,
- DDocData* inData)
- {
- if (!sIsRegistered) {
- RegisterClass ();
- }
-
- CCheckboxes* window;
- window = (CCheckboxes *)LWindow::CreateWindow(PPob_CheckboxesID, inSuperCommander);
- window->ConnectToData (inData);
- return window;
- }
-
- //----------
- #define RegisterClasses(AbstractClass,AMImpClass,GAImpClass) \
- RegisterClass_(AbstractClass); \
- if (useAppearance) { \
- RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID); \
- } else { \
- RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID); \
- }
-
- //----------
- void CCheckboxes::RegisterClass ()
- {
- Boolean useAppearance = UEnvironment::HasFeature (env_HasAppearance);
-
- RegisterClass_(CCheckboxes);
-
- // register the pane classes we use
- RegisterClasses (LCheckBox, LAMControlImp, LGACheckBoxImp);
- RegisterClasses (LDisclosureTriangle, LAMControlImp, LGADisclosureTriangleImp);
- RegisterClasses (LStaticText, LAMStaticTextImp, LGAStaticTextImp);
- RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
- RegisterClasses (CCheckBox, CustomControlImp, CustomControlImp);
- RegisterClass_(LToggleButton);
- RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
-
- sIsRegistered = true;
- }
-
- //----------
- CCheckboxes::CCheckboxes (
- LStream* inStream)
- : LWindow (inStream)
- {
- }
-
- //----------
- CCheckboxes::~CCheckboxes ()
- {
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void CCheckboxes::FinishCreateSelf ()
- {
- mStandardCheck = (LCheckBox*) FindPaneByID ('Stad');
-
- mXxCheck = (LDisclosureTriangle*) FindPaneByID ('Xx ');
-
- mLRCheck = (CCheckBox*) FindPaneByID ('LR ');
-
- mLR2Check = (CCheckBox*) FindPaneByID ('LR2 ');
-
- mLR3Check = (LToggleButton*) FindPaneByID ('LR3 ');
-
- mLR4Check = (LToggleButton*) FindPaneByID ('LR4 ');
-
- mCheckboxCheck = (CCheckBox*) FindPaneByID ('Chex');
-
- mCheckbox2Check = (LBevelButton*) FindPaneByID ('Che2');
-
- mNextCheck = (LBevelButton*) FindPaneByID ('Next');
-
- mNext2Check = (LBevelButton*) FindPaneByID ('Nex2');
-
-
- UReanimator::LinkListenerToControls(this, this, RidL_CheckboxesID);
- // "connect" self to our controls that we want to "listen" to
-
- // any additional initialization for your window:
- }
-
- //----------
- void CCheckboxes::ConnectToData (
- DDocData* inData)
- {
- mData = inData;
- mData->AddListener (this);
-
- mStandardCheck->SetValue (mData->GetStandard ());
- mXxCheck->SetValue (mData->GetXx ());
- mLRCheck->SetValue (mData->GetLR ());
- mLR2Check->SetValue (mData->GetLR2 ());
- mLR3Check->SetValue (mData->GetLR3 ());
- mLR4Check->SetValue (mData->GetLR4 ());
- mCheckboxCheck->SetValue (mData->GetCheckbox ());
- mCheckbox2Check->SetValue (mData->GetCheckbox2 ());
- mNextCheck->SetValue (mData->GetNext ());
- mNext2Check->SetValue (mData->GetNext2 ());
- }
-
- //----------
- void CCheckboxes::DataChanged (
- long inDataID)
- {
- StopListening ();
-
- if (inDataID == idStandard) {
- mStandardCheck->SetValue (mData->GetStandard ());
- }
- if (inDataID == idXx) {
- mXxCheck->SetValue (mData->GetXx ());
- }
- if (inDataID == idLR) {
- mLRCheck->SetValue (mData->GetLR ());
- }
- if (inDataID == idLR2) {
- mLR2Check->SetValue (mData->GetLR2 ());
- }
- if (inDataID == idLR3) {
- mLR3Check->SetValue (mData->GetLR3 ());
- }
- if (inDataID == idLR4) {
- mLR4Check->SetValue (mData->GetLR4 ());
- }
- if (inDataID == idCheckbox) {
- mCheckboxCheck->SetValue (mData->GetCheckbox ());
- }
- if (inDataID == idCheckbox2) {
- mCheckbox2Check->SetValue (mData->GetCheckbox2 ());
- }
- if (inDataID == idNext) {
- mNextCheck->SetValue (mData->GetNext ());
- }
- if (inDataID == idNext2) {
- mNext2Check->SetValue (mData->GetNext2 ());
- }
-
- StartListening ();
- }
-
- //----------
- void CCheckboxes::ListenToMessage (
- MessageT inMessage,
- void* ioParam)
- {
- switch (inMessage) {
- case msgDataChanged:
- DataChanged ((long)ioParam);
- break;
-
- case msgStandard:
- mData->SetStandard (mStandardCheck->GetValue ());
- break;
-
- case msgXx:
- mData->SetXx (mXxCheck->GetValue ());
- break;
-
- case msgLR:
- mData->SetLR (mLRCheck->GetValue ());
- break;
-
- case msgLR2:
- mData->SetLR2 (mLR2Check->GetValue ());
- break;
-
- case msgLR3:
- mData->SetLR3 (mLR3Check->GetValue ());
- break;
-
- case msgLR4:
- mData->SetLR4 (mLR4Check->GetValue ());
- break;
-
- case msgCheckbox:
- mData->SetCheckbox (mCheckboxCheck->GetValue ());
- break;
-
- case msgCheckbox2:
- mData->SetCheckbox2 (mCheckbox2Check->GetValue ());
- break;
-
- case msgNext:
- mData->SetNext (mNextCheck->GetValue ());
- break;
-
- case msgNext2:
- mData->SetNext2 (mNext2Check->GetValue ());
- break;
-
- default:
- ; // do something
- break;
- }
- }
-
- //----------
- Boolean CCheckboxes::ObeyCommand (
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true;
-
- if (inCommand < 0) {
- // modal dialog has finished
-
- switch (-inCommand) {
- }
-
- } else {
- switch (inCommand) {
-
- default:
- cmdHandled = LWindow::ObeyCommand(inCommand, ioParam);
- break;
- }
- }
-
- return cmdHandled;
- }
-
- //----------
- void CCheckboxes::FindCommandStatus (
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
-
- default:
- LWindow::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-